<!--#include file="../nav/top.php" -->
<!--#include file="../nav_menu/user_begin.php" -->
<style type="text/css">
#searchuser {
border: 0 solid #CC3300;
margin: 10px auto;
overflow-x: scroll;
text-align: center;
width: 750px;
display:none;
}



table.sourcetb{
border-collapse:collapse;
}
table.sourcetb th{
width:120px;
border: 1px solid #CCCCCC;
background-color: #E2F4C4;
padding: 5px;
text-align: center;
vertical-align: top;
}
table.sourcetb td{
border: 1px solid #CCCCCC;
background-color: #fcfcfc;
padding: 5px;
text-align: center;
vertical-align: top;
}
</style>
		<div class="infotitle">
			溯源查询
		</div>  
		<div style="margin:15px auto">
			<span style="color:#555;">请输入配送批次编号：</span>
			<span style="margin-left:5px;">
			 <input type="text" maxlength="50" id="code" class="textBox" value="" />
				<button  onclick="fnSearchs()"   class="userbtn">查询</button>
			</span>	
		</div> 
		<div id="searchuser" >
			 
		</div> 	
	 
		

<script type="text/javascript">
var url_vegesource = '/user/vegesource'; 



var pro_fields = {json_encode($pro_fields)};
var make_fields = {json_encode($make_fields)};
var send_fields = {json_encode($send_fields)};

$().ready(function(){
	
	('#code').focus();
});
function fnSearchs(){
	var code = $.trim($('#code').val());
	if(code == ''){
		alert('请输入配送批次编号！');
		$('#code').focus();
		return false;
	}
	$('#searchuser').show();
	$('button').attr('disabled','disabled');
	$('#searchuser').html('加载中......');
	$.post(
		url_vegesource,
		{
			code:code
		},
		function(e){
			var ok = errorHandler(e);
			if(ok && ok.success=='1'){
				fnBuildUserSource(ok.results);
			}else{
				$('#searchuser').html('暂无溯源信息');
			}
			$('button').attr('disabled','');
		}
	);
}
function fnBuildUserSource(rs){
	var totallength = pro_fields.length + make_fields.length + send_fields.length ;
	totallength = ((totallength+13)*132)+20;
	var str = '<div style="width:'+totallength+'px">';
	str += '<table class="sourcetb" >';
	str += '	<tr>';
	str += '		<th>品类</th>';
	str += '		<th>品名</th>';
	str += '		<th>基地</th>';
	str += '		<th>海拔（米）</th>';
	str += '		<th>采收时间</th>';
	str += '		<th>采收人员</th>';
	str += '		<th>采收质检员</th>';
	str += '		<th>空运时间</th>';
	for(var kk=0; kk<pro_fields.length; kk++){
		str += '		<th>'+pro_fields[kk].field_name+'</th>';
	}
	str += '				<th>入库时间</th>';
	str += '				<th>加工包装时间</th>';
	str += '				<th>加工质检员</th>';
	for(var kk=0; kk<make_fields.length; kk++){
		str += '		<th>'+make_fields[kk].field_name+'</th>';
	}
	str += '				<th>出库时间</th>';
	str += '				<th>配送人员</th>';
	for(var kk=0; kk<send_fields.length; kk++){
		str += '		<th>'+send_fields[kk].field_name+'</th>';
	}
	str += '			</tr>';

	for(var i=0; i<rs.length; i++){
		var obj = rs[i];
		str += '<tr>';
		str += '<td>'+obj.vegetype_name+'</td>';
		str += '<td>'+obj.vege_name+'</td>';
		str += '<td>'+obj.pro_base+'</td>';
		str += '<td>'+obj.pro_height+'</td>';
		str += '<td>'+obj.pro_picktime+'</td>';
		str += '<td>'+obj.pro_pickman+'</td>';
		str += '<td>'+obj.pro_testman+'</td>';
		str += '<td>'+obj.pro_plantime+'</td>';
		for(var kk=0; kk<pro_fields.length; kk++){
			str += '		<td>'+obj[pro_fields[kk].id]+'</th>';
		}
		str += '<td>'+obj.make_intime+'</td>';
		str += '<td>'+obj.make_time+'</td>';
		str += '<td>'+obj.make_testman+'</td>';
		for(var kk=0; kk<make_fields.length; kk++){
			str += '		<td>'+obj[make_fields[kk].id]+'</th>';
		}
		str += '<td>'+obj.send_outtime+'</td>';
		str += '<td>'+obj.send_man+'</td>';
		for(var kk=0; kk<send_fields.length; kk++){
			str += '		<td>'+obj[send_fields[kk].id]+'</th>';
		}
		str += '</tr>';
	}
	str += '</table>';
	str += '</div>';
	$('#searchuser').html('');
	$('#searchuser').html(str);
}

 
 
 
</script>	 	


<!--#include file="../nav_menu/user_end.php" -->
<!--#include file="../nav/bottom.php" -->